/**
 * This class is used to draw a rectangular shape and store information about it
 * * @author  Lorenzo Baracchi <lorenzo.baracchi@usi.ch>
 * 
 * Thanks to Simon Sarris www.simonsarris.com for the tutorial
 * 
 * @param x
 * @param y
 * @param w the width
 * @param h the height
 * @param fill color
 * @returns
 */
function Shape(x, y, w, h, fill) {
	this.x = x;
	this.y = y;
	this.w = w;
	this.h = h;
	this.fill = fill;
	this.selected = false;
	this.over = false;

	this.draw = function(ctx) {
		ctx.fillStyle = this.fill;
		ctx.fillRect(this.x, this.y, this.w, this.h);
	}

	this.contains = function(mx, my) {
		// All we have to do is make sure the Mouse X,Y fall in the area between
		// the shape's X and (X + Height) and its Y and (Y + Height)
//		alert(this.x+" "+(this.x+this.w)+", "+this.y+" "+(this.y+this.h)+" - "+mx+" "+my)
		return (this.x <= mx) && (this.x + this.w >= mx) && (this.y <= my) && (this.y + this.h >= my);
	}
}
